<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

use backend\assets\FancyBoxAsset;
FancyBoxAsset::register($this);
/* @var $this yii\web\View */
/* @var $model common\models\business\NewBusinessInspection */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'New Business Inspections', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
            <?= Html::a('返回','javascript:history.back(-1)'); ?>
            <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">

                <div class="new-business-inspection-view">

                    <p>
                        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                        <?= Html::a('删除', ['delete', 'id' => $model->id], [
                            'class' => 'btn btn-danger',
                            'data' => [
                                'confirm' => '您确定删除此项吗?',
                                'method' => 'post',
                            ],
                        ]) ?>
                    </p>

                    <?= DetailView::widget([
                        'model' => $model,
                        'attributes' => [
                            'id',
                            'business_person',
                            'pigid',
                            'pig.no',
                            [
                                'label' => '代养农户',
                                'attribute' => 'pig.liveryperson.name',
                            ],

                            [
                                'attribute' => 'createtime',
                                'value' => function($model){
                                    return date('Y-m-d',$model->createtime);
                                }
                            ],
                            'lat',
                            'lng',
                            'address',
                            [
                                'attribute' => 'status',
                                'value' => function($model){
                                    return \common\models\business\NewBusinessInspection::$statues[$model->status];
                                }
                            ],
                            'remark',
                        ],
                    ]) ?>


                    <div class="row">
                        <div class="panel panel-default">
                            <div class="panel-heading">巡检记录</div>
                            <div class="panel-body">
                                <div class="col-md-12">
                                    <?php foreach ($simpledata as $key => $row){  ?>
                                    <div class="col-md-4" style="margin-bottom: 10px;">
                                            <span><?= $row['fieldname'] ?></span> : <span><?= $row['val'] ?></span>
                                    </div>
                                    <?php } ?>
                                </div>
                                <div class="col-md-12">
                                    <?php foreach ($imgdata as $key => $row){  ?>
                                        <div class="col-md-12" style="margin-bottom: 10px;">
                                            <span><?= $row['fieldname'] ?></span> :
                                            <?php $imgs = \common\components\Upload::checkGetUrl($row['val'],true);
                                                foreach ($imgs as $k => $v) { ?>
                                                    <a class="fancybox" rel="<?=$key?>" href="<?= $v ?>"><img src="<?= $v ?>" alt="" style="width: 200px;height: 200px;"></a>
                                            <?php } ?>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</section>


<script>
    <?php $this->beginBlock('js_end') ?>
    //点击预览图片
    $('.fancybox').fancybox({
        'titlePosition' : 'over',
        'cyclic'        : true,
        'height':500
    });
    <?php $this->endBlock(); ?>
    <?php $this->registerJs($this->blocks['js_end'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>

</script>
